<template>
    <div class="page-hire-fav">
        <van-tabs v-model="active">
            <van-tab key="designer" title="关注的设计师">
                <ul class="designer-list">
                    <li class="designer-item van-hairline--bottom" v-for="item in designers" :key="item.id">
                        <div class="person" @click="readDetail(item.id)">
                            <div class="avatar">
                                <img v-if="item.headimgurl" :src="item.headimgurl" alt="">
                                <img v-else src="@/assets/img/avatar.png" alt="">
                            </div>
                            <div class="txt">
                                <p class="main">
                                    {{item.userName}}
                                    
                                </p>
                                <p class="tags">
                                    <span>#擅长日系风#</span>
                                    <span>#脑洞大开#</span>
                                </p>
                                <p class="infos">
                                    <van-tag plain type="primary">
                                        作品{{item.worksNum}}个
                                    </van-tag>
                                    <van-tag plain type="primary">
                                        接单{{item.orderNum}}次
                                    </van-tag>
                                </p>
                            </div>
                        </div>
                    </li>
                </ul>
            </van-tab>
            <van-tab key="works" title="收藏的图集">
                <app-works :data-source="works"></app-works>
            </van-tab>
        </van-tabs>
    </div>
</template>

<script>
import appWorks from '../../component/works'
import appDesigners from '../../component/designers'
import { collectionDesigner , collectionWorks } from '../../api/user'
export default {
    name: 'favDesigners',
    components: {
        appWorks, appDesigners
    },
    data(){
        return {
            active: 0,
            works: [],
            designers: [],
        }
    },
    methods: {
        getWorksList(){
            collectionWorks().then(rsp => {
                if(rsp.code === 200){
                    this.works = rsp.data
                }
            })
        },

        getDesignerList(){
            collectionDesigner().then(rsp => {
                if(rsp.code === 200){
                    this.designers = rsp.data
                }
            })
        }
    },
    created(){
        this.getDesignerList()
        this.getWorksList()
    }
}
</script>

<style lang="less">
.page-hire-fav{
    .van-tab--active{
        color: @primary;
    }
    .van-tabs__line{
        background-color: @primary;
    }

    .designer-list{
        padding: 0 15px;
        .designer-item{
            padding: 15px 0;
            &:after{
                border-color: #ccc;
            }
            .person{
                display: flex;
                align-items: center;
                .avatar{
                    width: 60px;
                    height: 60px;
                    margin-right: 10px;
                    border-radius: 50%;
                    overflow: hidden;
                }
                .txt{
                    flex: 1;
                    line-height: 1.4;
                    .main{
                        font-size: 15px;
                    }
                    .tags{
                        &>span{
                            display: inline-block;
                            font-size: 12px;
                            margin-right: 5px;
                            color: #999;
                        }
                    }
                    .infos{
                        .van-tag{
                            margin-right: 5px;
                        }
                    }
                }
            }
        }
    }
}
</style>